package com.qf.git04.demo02;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

@WebServlet("/new")
public class LoginAgain extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //中文乱码
        resp.setContentType("text/html;charset=utf-8");
        //获取session对象
        HttpSession session = req.getSession();
        User user = (User) session.getAttribute("user");
        if(user!=null){
            //响应客户端
            resp.getWriter().println(user.getUname()+"欢迎您");
        }

    }
}
